package fr.neyb.bernouilli.problem019;


public class Entry {

	private final static int startYear = 1901;
	private final static int endYear = 2000;

	public static void main(String... args) throws Exception {
		int nbMonday = 0;
		int dayDec = 0;

		int currMonth = 1;
		int currYear = 1900;

		while (currYear <= endYear) {

			dayDec = (dayDec + getNbDaysIn(currMonth, currYear)) % 7;

			if (currMonth == 12) {
				currMonth = 1;
				++currYear;
			} else {
				++currMonth;
			}

			if (dayDec == 6 && currYear >= startYear && currYear <= endYear)
				++nbMonday;

		}

		System.out.println(nbMonday);

	}

	private static int getNbDaysIn(int month, int year) {
		switch (month) {
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			return 31;

		case 4:
		case 6:
		case 9:
		case 11:
			return 30;
		case 2:
			return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) ? 29
					: 28;
		default:
			throw new IllegalArgumentException();
		}
	}
}
